<template>
  <div class="mnt-dialog form-container">
    <el-form ref="form" :model="formModel" label-width="100px">
      <el-row style="text-align: center">
        <el-col :span="12">
          <el-form-item label="扫描工位:" prop="uloc">
            <el-input v-model="formModel.uloc" disabled/>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row style="text-align: center">
        <el-col :span="12">
          <el-form-item label="车辆VIN:" prop="vin">
            <el-input ref="vin" :disabled="disabledVin" v-model="formModel.vin" @blur="inputblur" @keyup.enter.native="handlerScan"></el-input>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <hey-table ref="table" :columns="columns">

    </hey-table>
  </div>
</template>

<script>

  import {mapGetters} from "vuex";

  export default {
    name: 'PassPointsScanList',
    components: {

    },
    props: {},
    data() {
      return {
        tableData:[],
        disabledVin:true,
        formModel: {
          ulocNo:'',
          uloc:'',
          vin:'',
          isDelete:'0',
        },
        columns: [
          { title: '车辆VIN号', key: 'vin'},
          { title: '扫描类型', key: 'scanType',clcd:'scan_type_cd'},
          { title: '工艺路线代码', key: 'routeNo'},
          { title: '工艺路线名称', key: 'routeName'},
          { title: '扫描工位代码', key: 'ulocNo'},
          { title: '扫描工位名称', key: 'ulocName'},
          { title: '扫描时间', key: 'scanTime'},
          { title: '扫描用户', key: 'scanUsername'},
          { title: '整车物料号', key: 'materialNo'},
          { title: '物料描述', key: 'materialDesc'},
          { title: '车型', key: 'productTypeKey',clcd:'key_product_type'},
          { title: '是否SET IN', key: 'isSetIn',clcd:'ind_cd'},
        ],
      }
    },
    computed: {
      ...mapGetters([
        'name'
      ])
    },
    mounted() {
      //校验该用户是否拥有扫描工位权限
      const param = {}
      this.get('/trScanRecord/checkUserUloc', param).then(res => {
        this.formModel.uloc = res[0].ulocNo + '-' +res[0].ulocName
        this.formModel.ulocNo = res[0].ulocNo
        this.disabledVin = false
        //获取焦点
        this.$nextTick(() => {
          this.$refs.vin.focus()
        })
        this.queryList()
      })
    },
    methods: {
      inputblur(){
        this.$nextTick(() => {
          this.$refs.vin.focus()
        })
      },
      handlerScan(){
        if(!this.formModel.vin){
          this.$warn('车辆VIN号不能为空!')
          return false
        }
        const param = {}
        param.ulocNo = this.formModel.ulocNo
        param.vin = this.formModel.vin
        param.isDelete = '0'
        const url = '/trScanRecord/passPointsScan'
        this.post(url, param).then(res => {
          this.$info('扫描过点成功!', () => {
            this.formModel.vin = ''
            this.queryList()
          })
        })
      },
      queryList() {
        //查当前用户,当前扫描工位,当天的过点车辆信息
        const param = {}
        param.scanUsername = this.name
        param.ulocNo = this.formModel.ulocNo
        param.scanDate = new Date()
        param.isDelete = '0'
        this.$refs.table.query('/trScanRecord/queryTrScanRecord', param, '', false)
      },
    }
  }
</script>

<style lang="scss" >

</style>





